Learning Objectives

After completing this lesson, you'll be able to:

In this lesson, you will:

Resources

AI Connectors in FME

FME connects workspaces to AI models through AI connector transformers. Each connector sends a request to an AI service and adds the model's response to the feature as attributes, so you can use AI in the middle of a workspace like any other transformer. The OpenAIConnector, used in this course, connects to OpenAI and to OpenAI-compatible services, such as Azure OpenAI and locally hosted models like Ollama. Connectors for other AI providers are available on FME Hub, and they follow the same pattern. 

The AI connector transformers share a common pattern of parameters you must configure to use them:

Prompts

The Create Response action takes two kinds of prompts:

Effective prompts for workflow automation are explicit. State the task, give the model all the data it needs, list the rules it must follow (including what it must not do, such as inventing tool names), and describe the exact output you expect. Clear rules make the model's answers more consistent from run to run. In the exercise, the rules and the data are both in the User Prompt so you can see the whole request in one place.

Structured Output

By default, a model answers in free text, which may be difficult to integrate into your workspace consistently. When you enable Structured Output and provide a JSON Schema, the OpenAIConnector requires the response to match that schema exactly. The response always contains the properties and types you define as JSON, so downstream transformers can rely on it.

The Create Response action adds these attributes to each feature:

Advanced options, such as Temperature, control how varied the model's answers are. Lower values give more predictable responses.

Use AI to Select an MCP Tool

MCP tool definitions intentionally give AI models readable, consistent information. Each tool has a name, natural language description, and a structured input schema, all of which an AI needs to understand what a tool does and how to use it. Instead of hardcoding which tool to call, your workspace can let an AI model decide at runtime using user input data and a list of available MCP tools. 

An MCPCaller uses List Tools to retrieve the full set of tools available on an MCP server. An AI connector takes the tool list and the user's request as input, evaluates them to select the most appropriate tool, then outputs the selected tool name and the structured input for that tool, using structured output so the result is always in the same shape. In the next lesson, you will pass this output to a second MCPCaller that calls the selected tool.

Exercise

Note

This exercise continues where the FME as an MCP Client exercise left off. You should complete the previous exercise before continuing with this one.

Frank, a GIS Administrator, has already used FME's MCPCaller in the FME as an MCP Client exercise to connect to a weather MCP server, list its available tools, and call a tool. Instead of hardcoding a tool into an MCPCaller for every kind of request, he wants an AI model to read the server's tool list and choose the right tool for a user's request. The AI must also format the input that the selected tool expects.

In this exercise, you will:

1) Open Starting Workspace

2) Create User Parameter

The easiest method to take user input to control how the workspace runs is with user parameters. 

Get the current weather forecast for Vancouver

3) Edit the List Tools MCPCaller

For the dynamic tool selection workflow, you want the List Tools MCPCaller to return only one record with information about all the tools. With individual records for each tool, a downstream AI connector can only analyze one tool at a time. 

4) Add an AttributeCreator

5) Run and Save

6) Add and Configure OpenAIConnector 

The OpenAIConnector analyzes the available MCP tools and selects the best one for the user's request. 

You are selecting a weather MCP tool based on a user request.

Available tools, including descriptions and input schemas:
@Value(all_mcp_tools)

User request:
@Value(user_request)

Your task:
Select the most appropriate weather tool and construct the tool_input that matches the selected tool's input schema exactly.

Rules:
- You MUST select tool_name exactly from the provided tool list.
- You MUST provide a tool_input that matches the input schema of the selected tool.
- Do not rename tools or invent new ones.
- Vancouver coordinates are latitude: 49.2827, longitude: -123.1207, timezone: "America/Vancouver".
- Use these coordinates for any location-based tool unless the user specifies a different location.
- If you do not know the geographic coordinates from the place name from the user request, estimate the coordinates from your knowledge to format the tool input.
- For weather_archive, today's date is @Value(today) — use a reasonable past date range.
- Do not use the geocoding tool. 


Schema rules:
- tool_input must strictly follow the input schema of the selected tool.
- Preserve object structure and nesting exactly.
- Include all required fields.
- Do not add fields not defined in the schema.

Copying and Pasting in Strigo Labs

This course requires a lot of copying and pasting to avoid typing out JSON and descriptions. To copy and paste content into your Strigo lab:

If you're having trouble pasting into the Strigo lab, log into the FME Academy in a browser in the lab and copy (Ctrl + C) and paste (Ctrl + V) directly within the lab. 

{
  "type": "object",
  "properties": {
    "tool_name": {
      "type": "string"
    },
    "tool_input": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "required": ["tool_name", "tool_input"],
  "additionalProperties": false
}

7) Add a JSONFlattener

To send output from the OpenAIConnector as attributes to the Call Tool MCPCaller, you need to parse the output JSON into attributes.

8) Test the Tool Selection

The tool_name and tool_input attributes show which tool the AI selected and the input it formatted for that tool. In the next lesson, the Call Tool MCPCaller will take these exposed attributes as input.

You have built an AI-driven tool selector that reads the weather MCP server's tool list and returns the tool and input that match a user's request.